package com.aidex.biz.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.biz.domain.MonthModelDetials;
import com.aidex.biz.service.MonthModelDetialsService;
import com.aidex.common.utils.SecurityUtils;

/**
 * 月报模版配置详情Controller
 * @author sean
 * @email 2074844820@qq.com
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/biz/bizMonthModelDetials")
public class MonthModelDetialsController extends BaseController
{
    @Autowired
    private MonthModelDetialsService monthModelDetialsService;

    /**
     * 查询月报模版配置详情列表
     */
    @GetMapping("/list")
    public R<PageInfo> list(MonthModelDetials monthModelDetials, HttpServletRequest request, HttpServletResponse response)
    {

        monthModelDetials.setPage(new PageDomain(request, response));
        return R.data(monthModelDetialsService.findPage(monthModelDetials));
    }

    /**
     * 获取月报模版配置详情详细信息
     */
    @GetMapping(value = "/{id}")
    public R<MonthModelDetials> detail(@PathVariable("id") String id)
    {
        return R.data(monthModelDetialsService.get(id));
    }

    /**
     * 新增月报模版配置详情
     */
    @Log(title = "月报模版配置详情", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  MonthModelDetials monthModelDetials)
    {
        return R.status(monthModelDetialsService.save(monthModelDetials));
    }

    /**
     * 修改月报模版配置详情
     */
    @Log(title = "月报模版配置详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated MonthModelDetials monthModelDetials)
    {
        return R.status(monthModelDetialsService.save(monthModelDetials));
    }


    /**
     * 删除月报模版配置详情
     */
    @Log(title = "月报模版配置详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(monthModelDetialsService.deleteMonthModelDetialsByIds(ids));
    }

    /**
     * 获取最大编号
     */
    @GetMapping("/findMaxSort")
    public R findMaxSort()
    {
        return R.data(monthModelDetialsService.findMaxSort(new MonthModelDetials()));
    }

    /**
     * 导出月报模版配置详情列表
     */
    @Log(title = "月报模版配置详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(MonthModelDetials monthModelDetials)
    {


        List<MonthModelDetials> list = monthModelDetialsService.findList(monthModelDetials);
        ExcelUtil<MonthModelDetials> util = new ExcelUtil<MonthModelDetials>(MonthModelDetials.class);
        return util.exportExcel(list, "月报模版配置详情数据");
    }

}
